package com.zmx.patientend.adapter;

import android.app.Activity;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.wang.adapters.adapter.BaseAdapterRvList;
import com.wang.adapters.base.BaseViewHolder;
import com.zmx.patientend.R;
import com.zmx.patientend.pojo.Doctor;
import com.zmx.patientend.view.util.ViewStar;

import java.util.Random;

import butterknife.BindView;
import butterknife.ButterKnife;

public class DoctorItemAdapter extends BaseAdapterRvList<DoctorItemAdapter.ViewHolder, Doctor> {
    public DoctorItemAdapter(Activity activity) {
        super(activity);
    }

    @Override
    protected void onBindVH(ViewHolder holder, int listPosition, Doctor doctor) {

        holder.name.setText(doctor.getName());
        holder.describe.setText(doctor.getClass_name()+"  "+doctor.getTitle_name());
        holder.addres.setText(doctor.getHosp_name());
        holder.bei.setText("擅长："+doctor.getExpertise());
        int ran = (int) (Math.random()*1000);
        holder.number.setText( ran+"人咨询");
        Glide.with(mActivity).load(doctor.getAvatar()).into(holder.head);
        float f = 5f;
        holder.ratingbar.setStar(f);
        holder.ratingbar.setClickable(false);

    }

    @NonNull
    @Override
    protected ViewHolder onCreateVH(ViewGroup parent, LayoutInflater inflater) {

        ViewHolder holder = new ViewHolder(inflater.inflate(R.layout.adapter_doctor, parent, false));
        return holder;

    }

    static class ViewHolder extends BaseViewHolder {

        @BindView(R.id.head)
        ImageView head;
        @BindView(R.id.name)
        TextView name;
        @BindView(R.id.describe)
        TextView describe;
        @BindView(R.id.addres)
        TextView addres;
        @BindView(R.id.bei)
        TextView bei;
        @BindView(R.id.number)
        TextView number;
        @BindView(R.id.ratingbar)
        ViewStar ratingbar;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

    }

}
